#include "linux-alsa-sound.h"

int main(int argc, char const *argv[])
{

	LinuxAlsaSound alsaSound;

	bool ok = alsaSound.open("plughw:1,0", SND_PCM_STREAM_CAPTURE);
	if(!ok)
	{
		fprintf(stderr, "Fail to alsasound open plughw:1,0\n");
		return -1;
	}

	pcm_hw_params_t parms = {
	    .access = SND_PCM_ACCESS_RW_INTERLEAVED,
	    .format = SND_PCM_FORMAT_S16_LE,
	    //   SND_PCM_FORMAT_S16_LE
	    .channels   = 1,
	    .sampleRate = 16000,
	    .sampleBits = 16,
	    .frames     = 32,
	};

	ok = alsaSound.setParams(&parms);
	if(!ok)
	{
		fprintf(stderr, "Fail to alsasound set params\n");
		return -1;
	}

	//ok = alsaSound.recordPCMData(15, "test.pcm");
	ok = alsaSound.recordWAVData(15, "test.wav");
	cout << "record pcm data,ok:" << ok << endl;

	return 0;
}
